<#include "/common/head.ftl">

<@showTitle title="${i18n.getMessage('placementTest')} > ${i18n.getMessage('add')}">
	<a href="#" onclick="cc('student/showListPlacementTest.sgt?studentId=${(student.id)!}')">${i18n.getMessage('list')}</a>
	- <a href="#" onclick="cc('student/showInfoStudent.sgt?id=${(student.id)!}')">${i18n.getMessage('student')}</a>
</@showTitle>

<div id="error" style="display:none"></div>

<form action="student/addPlacementTest.sgt" validator="student/validatePlacementTest.sgt" onsubmit="submitFormValidation(this); return false;" onreset="$('error').hide()">
	<input type="hidden" name="studentId" value="${student.id}"/>
		
	<table id="dataTable" cellspacing="5" align="center" cellpadding="0" style="width: 600px;">
		<tr> 
			<td class="name">${i18n.getMessage('student')}:</td>
			<td>${(student.fullName)!}</td>
		</tr>	
		<tr>
			<td class="name">${i18n.getMessage('level')}:</td>
			<td>
				<select name="levelId" id="levelId" style="width:205px">
					<option></option>
					<#list programs as program>
						${request.setAttribute("levels", program.levels)}
						<optgroup label="${program.name}">
							<#list levels as level>
								<option value="${level.id}">${level.name}</option>
							</#list>
						</optgroup>
					</#list>
				</select>
			</td>
		</tr>
		<tr>
			<td class="name"><@required/>${i18n.getMessage('testDate')}:</td>
			<td><input type="text" name="date" value="${(student.testDate?date)!}" style="width:200px"/><img class="calendarImg" src="images/calendar/calendar.gif" onclick="displayCalendar(document.forms[0].date, '${i18n.getMessage('format.date')}', this)"/></td>
		</tr>
		<tr>
			<td class="name">${i18n.getMessage('testTime')}:</td>
			<td>
				<select name="placementShiftId" style="width:204px">
					<option></option>
					<#list shifts as shift>
						<option value="${(shift.id)!}">${(shift.startTime?time)!}-${(shift.endTime?time)!}</option>
					</#list>
				</select>
			</td>
		</tr>
		<tr>
			<td class="name">${i18n.getMessage('score')}:</td>
			<td>
				${i18n.getMessage('written')}: <input type="text" name="writtenScore" style="text-align:center;width:43px"/>
				${i18n.getMessage('speaking')}: <input type="text" name="speakingScore" style="text-align:center;width:43px"/>
			</td>
		</tr>
		<#if student.type.id == 0>
			<#assign fee = 0>
		<#else>
			<#assign fee = ParameterService.find('FPT').value>
		</#if>
		<tr>
			<td class="name"><@required/>${i18n.getMessage('type')}:</td>
			<td>
				<select name="placementTestTypeId" class="w200" onchange="setFee(this)">
					<option></option>
					<#list types as type>
						<option value="${(type.id)!}" label="${(type.fee.amount)!}" title="${(type.description)!}">${(type.name)!}</option>
					</#list>
				</select>
			</td>
		</tr>
		<tr>
			<td class="name">${i18n.getMessage('fee')}:</td>
			<td>
				<input type="text" name="fee" readonly="readonly" class="right w200 dis"/> <span class="footnote">1</span>
			</td>
		</tr>
		<tr>
			<td class="name">${i18n.getMessage('registerDate')}:</td>
			<td><input type="text" name="registerDate" style="width:200px"/><img class="calendarImg" src="images/calendar/calendar.gif" onclick="displayCalendar(document.forms[0].registerDate, '${i18n.getMessage('format.date')}', this)"/></td>
		</tr>
		<tr>
			<td class="name">${i18n.getMessage('cashier')}:</td>
			<td>
				<select name="cashierId" style="width:204px">
					<option></option>
					<#list cashiers as cashier>
						<option value="${(cashier.id)!}" <#if action.USER().id == cashier.id>selected</#if>>${(cashier.fullName)!}</option>
					</#list>
				</select>
			</td>
		</tr>
		<tr>
			<td class="name" style="vertical-align:top">${i18n.getMessage('comment')}:</td>
			<td><textarea name="comment" style="width:350px;height:80px;"></textarea></td>
		</tr>
		<tr>
			<td></td>
			<td>
				<input type="submit" value="${i18n.getMessage('add')}" class="button_style"/> 
				<input type="reset" value="${i18n.getMessage('reset')}" class="button_style"/> 
			</td>
		</tr>
		<tr>
			<td></td>
			<td><p><span class="footnote">1</span>: Set fee to 0 in order to prevent receipt number increase automatically.</p></td>
		</tr>
	</table>
</form>

<script type="text/jsvascript">
setFee = function(elem) {
	desc = elem.options[elem.selectedIndex].title;
	fee = elem.options[elem.selectedIndex].label;
	
	elem.form.fee.value = fee;
	elem.form.comment.value = desc;
}
</script>